//*********************************************************************
// Copyright (C) 2014 Hell Prototypes / www.hellprototypes.com
// 
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or (at
// your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
//********************************************************************
#ifndef __UI_WIDGET_H
#define __UI_WIDGET_H

typedef void (*item_handle_f)(void);

/* Type define */
typedef struct{
	char *item_content;
	item_handle_f item_handle;
} UI_listmenu_item_t;

typedef struct{
	char 			*item_title;
	UI_listmenu_item_t	*p_items;
	uint8_t				items_num;
} UI_listmenu_t;

/* Define */
#define LISTMENU_CONFIRM		KEY_3WS_PUSH
#define LISTMENU_CANCLE		KEY_MAIN
#define LISTMENU_UP 			KEY_3WS_UP
#define LISTMENU_DOWN  		KEY_3WS_DOWN

void ui_listmenu(const UI_listmenu_t *p_listmenu);

//=============================================

typedef uint8_t (*memory_callback_f)(uint32_t);
/* Define */
#define HEX_EDITOR_EXIT				KEY_MAIN
#define HEX_EDITOR_CONFIRM			KEY_3WS_PUSH
#define HEX_EDITOR_PAGE_UP 			KEY_3WS_UP
#define HEX_EDITOR_PAGE_DOWN  		KEY_3WS_DOWN
#define HEX_EDITOR_LINE_UP 			KEY_TOP_LEFT
#define HEX_EDITOR_LINE_DOWN  		KEY_TOP_RIGHT
#define HEX_EDITOR_SECTION_UP 		KEY_BTM_LEFT
#define HEX_EDITOR_SECTION_DOWN  		KEY_BTM_RIGHT

#define HEX_EDITOR_LINE_SIZE			(1*8)
#define HEX_EDITOR_PAGE_SIZE			(7*HEX_EDITOR_LINE_SIZE)
#define HEX_EDITOR_SECTION_SIZE		(7*HEX_EDITOR_PAGE_SIZE)

#define HEX_EDITOR_BLOCK_SIZE			((uint32_t)16*1024)

void ui_hex_editor(uint32_t start, uint32_t length, memory_callback_f mem_read_f);

#endif
